package com.itheima.exception;

import com.itheima.entity.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalHandlerException {

    @ExceptionHandler
    public Result doException(Exception e) {
       log.error("程序出错了。。。",e);
        return Result.error("出错了，问问管理员吧！");
    }

    @ExceptionHandler
    public Result handleBusinessException(BusinessException e) {
        log.error("程序出错了。。。",e);
        return Result.error(e.getMessage());
    }
}
